

import lejos.nxt.I2CPort;
import lejos.nxt.SensorPort;
import lejos.nxt.UltrasonicSensor;


public class LejosUSsensor {

	private static UltrasonicSensor  us = new UltrasonicSensor(SensorPort.S1);
	private static boolean isContinuous = false;
	public static  void setUSSensorPort(I2CPort port){
		// FIXME  is THIS safe
		us = new  UltrasonicSensor(port);
	}
	
	/*Signaux autorisés
	 * UsOff,  UsReset,  Distance, Ping
	 * 
	 * */
	
	public static void inputUSOFF(){
		us.off();
	}

	public static void inputUSRESET(){
		us.reset();
	}
	
	public static void setContinuous(){
		us.continuous();
		isContinuous = true;	
	}
	public static  int  inputDISTANCE(){
	   	if (!isContinuous)
			setContinuous();		
		 return   us.getDistance();
	}
	
	public static void inputUSPING(){
		us.ping();
	}
	
	
	
	
}
